package com.tedu.bill.demo2;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * Author：毕龙
 * Date: 2024/5/24 10:44
 */
public class TestThreadMethod3 {
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName() + "\t" + i);
                }
                return null;
            }
        }));

        t1.start();
        //将线程1加入到主线程
        t1.join();

        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName()+"\t"+i);
        }

    }
}
